﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using Org.Eurekaa.DNJ.UI.Common;
using System.Collections;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Org.Eurekaa.DNJ.Settings;
using Org.Eurekaa.DNJ.Common;


namespace Org.Eurekaa.DNJ.UI.DNJSettings
{    
    [Serializable()]
    public class DNJSliderSettings : GenericSettingsObject
    {
        #region [ DNJ Settings ]

        [Description("Whether to slide handle smoothly when user click outside handle on the bar.")]
        [DefaultValue(false), NotifyParentProperty(true), RefreshProperties(RefreshProperties.Repaint)]
        public bool Animate
        {
            get { return Get<bool>("animate"); }
            set { this["animate"] = value; }
        }

        [Description("The maximum value of the slider.")]
        [DefaultValue(100), NotifyParentProperty(true), RefreshProperties(RefreshProperties.Repaint)]        
        public int Max
        {
            get { return Get<int>("max"); }
            set { this["max"] = value; }
        }

        [Description("The minimum value of the slider.")]
        [DefaultValue(0), NotifyParentProperty(true), RefreshProperties(RefreshProperties.Repaint)]
        public int Min
        {
            get { return Get<int>("min"); }
            set { this["min"] = value; }
        }

        [Description("The orientation of the slider.")]
        [DefaultValue(EnmOrientation.auto), NotifyParentProperty(true), RefreshProperties(RefreshProperties.Repaint)]
        public EnmOrientation Orientation
        {
            get { return Get<EnmOrientation>("orientation"); }
            set { this["orientation"] = value; }
        }

        [Description("If set to true, the slider will detect if you have two handles and create a stylable range element between these two. Two other possible values are 'min' and 'max'. A min range goes from the slider min to one handle. A max range goes from one handle to the slider max.")]
        [DefaultValue(false), NotifyParentProperty(true), RefreshProperties(RefreshProperties.Repaint)]        
        public bool Range
        {
            get { return Get<bool>("range"); }
            set { this["range"] = value; }
        }

        [Description("Determines the size or amount of each interval or step the slider takes between min and max. The full specified value range of the slider (max - min) needs to be evenly divisible by the step.")]
        [DefaultValue(1), NotifyParentProperty(true), RefreshProperties(RefreshProperties.Repaint)]
        public int Step
        {
            get { return Get<int>("step"); }
            set { this["step"] = value; }
        }

        [Description("Determines the value of the slider, if there's only one handle. If there is more than one handle, determines the value of the first handle.")]
        [DefaultValue(0), NotifyParentProperty(true), RefreshProperties(RefreshProperties.Repaint)]
        public int Value
        {
            get { return Get<int>("value"); }
            set { this["value"] = value; }
        }


        private Interval values = new Interval(0, 100);

        [Description("")]
        [PersistenceMode(PersistenceMode.Attribute),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [NotifyParentProperty(true), RefreshProperties(RefreshProperties.Repaint)]
        public Interval Values
        {
            get { return values; }
            set { values = value; }
        }

        #endregion


        public DNJSliderSettings()
        {
            Max = 100;
            Step = 1;
        }
        public override string ToString()
        {
            
            return base.ToString();
        }


        public override void PrepareJSON()
        {
            if (this.Range) this["values"] = values;
        }
    }
}
